﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Abstract
{
    class ConcreteFactory : AbstractFactory
    {
        Stock stockInstance = Stock.getInstance();
        // private List<Client> mClientsList ;

        /*public ConcreteFactory()
        {
            mClientsList=new List<Client>();
        }
        public void addClient(String name, String age, ConcreteFactory factory)
        {
            Client nou = new Client(name, age, this);
            mClientsList.Add(nou);
        }

        public void printClients()
        {
            foreach (Client c in mClientsList)
                c.aboutClient();


        }*/

        public override AbstractCar OrderCar(AbstractCar.Cars type, AbstractCar.Colors color, AbstractCar.Transmissions transmission)
        {
            AbstractCar car = null;
            if (type == AbstractCar.Cars.Sedan)
            {
                car = stockInstance.RetriveFromStock(type);
                if (car == null)
                {
                    car = new Sedan(type, color, transmission, Sedan.SedanFeatures.MP3decoder, Sedan.SedanEngines.Premium, Sedan.SedanCategories.Compact);
                    stockInstance.AddToStock(type, car);

                }

                return car;
            }

            if (type == AbstractCar.Cars.Mini)
            {
                car = stockInstance.RetriveFromStock(type);
                if (car == null)
                {
                    car = new Mini(type, color, transmission, Mini.MiniFeatures.Radio, Mini.MiniEngines.RegularGas, Mini.MiniCategories.Midsize);
                    stockInstance.AddToStock(type, car);

                }

                return car;
            }

            if (type == AbstractCar.Cars.Coupe)
            {
                car = stockInstance.RetriveFromStock(type);
                if (car == null)
                {
                    car = new Coupe(type, color, transmission, Coupe.CoupeFeatures.DVD, Coupe.CoupeEngines.Premium, Coupe.CoupeCategories.Fullsize);
                    stockInstance.AddToStock(type, car);

                }

                return car;
            }

            return car;
        }
    }
}
